package org.xtremeobjects.domain.model.java5;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class OperationSpecification extends AbstractMethodSpecification {

	public boolean isSatisfiedBy(Method method) {
		if(!isPublic(method))
			return false;

		if(isGetter(method) || isSetter(method) || isHidden(method))
			return false;
		
		if(isFromAOP(method))
			return false;
		
		if(isFromBase(method))
			return false;

		return true;
	}

	private boolean isFromBase(Method method) {
		return method.getDeclaringClass().getPackage().getName().startsWith("java");
		
	}

	private boolean isFromAOP(Method method) {
		return method.getName().startsWith("ajc");
	}

	private boolean isPublic(Method method) {
		return Modifier.isPublic(method.getModifiers());
	}

}
